﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//引入命名空间
using stwh_Model;
using stwh_BLL;
using stwh_Common;
using Newtonsoft.Json;
using stwh_Web.Handler.stwh_admin;

namespace stwh_Web.Handler.extend.huodong
{
    /// <summary>
    /// loadData 的摘要说明
    /// </summary>
    public class loadData : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            try
            {
                if (context.Request.HttpMethod.ToLower() == "post")
                {
                    //获取今日中奖用户数据
                    List<stwh_cjresult> ListData = new stwh_cjresultBLL().GetModelList("CONVERT(varchar(300),stwh_cjraddtime,120) like '" + DateTime.Now.ToString("yyyy-MM-dd") + "%' order by stwh_cjrid desc");
                    List<stwh_cjresult> newList = new List<stwh_cjresult>();
                    foreach (stwh_cjresult item in ListData)
                    {
                        stwh_cjresult mm = new stwh_cjresult();
                        mm.stwh_cjraddtime = item.stwh_cjraddtime;
                        mm.stwh_cjrmobile = item.stwh_cjrmobile.Substring(0, 3) +"****"+ item.stwh_cjrmobile.Substring(item.stwh_cjrmobile.Length - 3, 3);
                        mm.stwh_cjrid = item.stwh_cjrid;
                        newList.Add(mm);
                        break;
                    }
                    BaseHandler.SendResponseMsgs(context, "0", newList, newList.Count);
                }
                else BaseHandler.SendResponseMsgs(context, "-1", "数据传输方法错误，请采用post方式！", 0);
            }
            catch (Exception)
            {
                BaseHandler.SendResponseMsgs(context, "-1", "服务器异常，请稍后再试！", 0);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}